home *** CD-ROM | disk | FTP | other *** search
/ CYBER.XPO.95 / CYBER.XPO.95 (Arsenal Computer).ISO / popreq / amiga1 / dcdd_20.lha / Do_FAAX.rexx < prev    next >
OS/2 REXX Batch file  |  1993-09-06  |  9KB  |  326 lines

  1. /* 
  2.    Do_FAAX.rexx                   Version 1.9                     930906.0303
  3.  
  4.              (you can follow along on the ZZZ_FAAX_session_log file)
  5. */
  6.  
  7.  
  8.  
  9. address BAUD /* must have this here */
  10. OPTIONS RESULTS
  11.  
  12. parse arg N_args
  13.  
  14. parse var N_args PW1 PW2 Xargs
  15.  
  16. /*
  17. msg '************************'
  18. msg 'Args = ' PW1 ' ' PW2 ' ' Xargs
  19. msg '************************'
  20. */
  21.  
  22. timeout 30
  23.  
  24. auto = 'X'
  25. waitlost = ' '
  26.  
  27. if exists('ram:AUTO')~=0 then  
  28.    auto = 'y'
  29.  
  30. call LOGON
  31.  
  32. if auto = 'y' then do
  33.    if waitlost = 'n' then do  
  34.       call AUTO_NEW_FILE_LIST
  35.    end
  36. end 
  37.  
  38. if auto = 'y' then do
  39.    if waitlost = 'n' then do
  40.       if exists('dh1:-dl/DL_FAAX')~=0 then do  
  41.          call AUTO_FILE_DL
  42.          if waitlost = 'n' then do
  43. /*
  44.             address command 'rename dh1:-dl/DL_FAAX dh1:-dl/DL_FAAX_done'  
  45.  
  46.  if anyone can tell me why the above line will not work, while the next
  47.     two will, please let me know. I'm stumped!
  48. */
  49.             address command 'copy dh1:-dl/DL_FAAX dh1:-dl/DL_FAAX_done' 
  50.             address command 'delete dh1:-dl/DL_FAAX' 
  51.          end
  52.       end
  53.    end
  54. end 
  55.  
  56. if auto = 'y' then do
  57.    if waitlost = 'n' then do 
  58.       call LOGOFF
  59.    end
  60. end  
  61.  
  62. if waitlost ~= 'n' then do
  63.    if exists('RAM:continue')~=0 then do
  64.       address command 'delete RAM:continue'
  65.    end
  66. end
  67.  
  68. return
  69.  
  70.  
  71. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  72.  *                                                             *
  73.  *                   Functions / Subroutines                   *
  74.  *                                                             *
  75.  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  76.  
  77. LOGON:
  78. address BAUD /* must have this here */
  79.  
  80. waitlost = ' '
  81. waitlost_LO_hold = ' '
  82. PW_loop_count = 0
  83. do forever
  84. nput='C-Ya! Then,Escape twice,First and Last name:,Password:,password to use:,for verification:,continue,mail now? [Y/n]:,3 Posted by,quit):,NO CARRIER'
  85. wait nput
  86. NRC = RC
  87. NRESULT = RESULT
  88.    if NRC > 0 then do  /* waited 30 seconds & no nput items on serial port */
  89.       waitlost = 'y'
  90.       msg '****** LOGON - wait is LOST! ******'
  91.    end
  92.    if NRESULT = 'Escape twice' then              /* A */ 
  93.       send '\x1B\x1B'
  94.    if NRESULT = 'First and Last name:' then      /* B */ 
  95.       send 'Your Name\r'
  96.    if NRESULT = 'Password:' then do              /* C C1 C2 */
  97.       PW_loop_count = PW_loop_count + 1
  98.       if PW_loop_count = 1 then 
  99.          send PW1'\r'                            /* C C1 */
  100.       if PW_loop_count = 2 then do
  101.          if exists('DH1:-dl/FAAX_PW2_used')=0 then do
  102.             address command 'makedir DH1:-dl/FAAX_PW2_used' 
  103.          end
  104.          send PW2'\r'                            /* C2 */
  105.       end                                        
  106.       if PW_loop_count > 2 then do
  107.          waitlost = 'y'
  108.          msg '****** Logon PW_loop_count > 2 ******'
  109.       end
  110.    end
  111.    if NRESULT = 'password to use:' then          /* S */ 
  112.       send PW2'\r'
  113.    if NRESULT = 'for verification:' then         /* T */ 
  114.       send PW2'\r'
  115.    if NRESULT = 'Press enter...' then            /* D */ 
  116.       send '\r'
  117.    if NRESULT = 'continue' then                  /* E F */ 
  118.       send '\r'
  119.    if NRESULT = 'mail now? [Y/n]:' then do       /* G */
  120.       if auto = 'y' then do
  121.          send 'y\r'        
  122.          waitlost_LO_hold = waitlost
  123.          call MAIL_CALL
  124.          if waitlost = 'n' then do 
  125.             waitlost = waitlost_LO_hold
  126.             if exists('DH1:-dl/FAAX_MAIL_captured')=0 then do
  127.                address command 'makedir DH1:-dl/FAAX_MAIL_captured' 
  128.             end
  129.          end
  130.       end
  131.       else do
  132.          if exists('DH1:-dl/FAAX_MAIL_waiting')=0 then do
  133.             address command 'makedir DH1:-dl/FAAX_MAIL_waiting' 
  134.          end
  135.          send 'n\r' 
  136.       end
  137.    end
  138.    if NRESULT = '3 Posted by' then do            /* Q R */
  139.          if exists('DH1:-dl/FAAX_AlphaNews_captured')=0 then do
  140.             address command 'makedir DH1:-dl/FAAX_AlphaNews_captured' 
  141.          end
  142.          send '\w\r'
  143.    end
  144.    if NRESULT = 'quit):' then do                 /* U */
  145.       waitlost = 'n'
  146.       send '\r'
  147.    end
  148.    if NRESULT = 'C-Ya! Then' then                /* AM */
  149.       waitlost = 'X'
  150.    if NRESULT = 'NO CARRIER' then                /* if logon really gets  */
  151.       waitlost = 'y'                             /*          LOST         */
  152.                                                  /* this will get you OUT */ 
  153.    if waitlost ~= ' ' then
  154.       leave
  155. end
  156. return
  157.  
  158. MAIL_CALL:
  159. address BAUD /* must have this here */
  160.  
  161. waitlost = ' '
  162. do forever
  163. nput='More(Y/n/=),(E)nter? (S)top:,(F)iles? (S)top:,to continue:,(Enter to continue):,(A)bort:,here [y/N],End of messages'
  164.  
  165. /* note use of ? to allow entry of a comma into nput above "(E)nter? (S)top:" */
  166.  
  167. wait nput
  168. NRC = RC
  169. NRESULT = RESULT
  170.    if NRC > 0 then do /* waited 30 seconds & no nput items on serial port */
  171.       waitlost = 'y'
  172.       msg '****** MAIL_CALL - wait is LOST! ******'
  173.    end
  174.    if NRESULT = 'More(Y/n/=)' then               /* ? */ 
  175.       send '='
  176.    if NRESULT = '(E)nter, (S)top:' then          /* H N O */ 
  177.       send 'n\r'
  178.    if NRESULT = '(F)iles, (S)top:' then          /* I */ 
  179.       send 'f\r'
  180.    if NRESULT = 'to continue:' then              /* J */ 
  181.       send '\r'
  182.    if NRESULT = '(Enter to continue):' then      /* K */ 
  183.       send '\r'
  184.    if NRESULT = '(A)bort:' then                  /* L */ 
  185.       send 's\r'
  186.    if NRESULT = 'here [y/N]' then                /* M */ 
  187.       send 'y\r'
  188.    if NRESULT = 'End of messages' then           /* P */ 
  189.       waitlost = 'n'
  190.    if waitlost ~= ' ' then 
  191.       leave
  192. end
  193. return 
  194.  
  195.  
  196. AUTO_NEW_FILE_LIST:
  197. address BAUD /* must have this here */
  198.  
  199. waitlost = ' '
  200. TL_loop_count = 0
  201. do forever
  202. nput='Command ->,Enter Disk Number:,Time Left [,Search Date,Previous Page:'
  203. wait nput
  204. NRC = RC
  205. NRESULT = RESULT
  206.    if NRC > 0 then do  /* waited 30 seconds & no nput items on serial port */
  207.       waitlost = 'y'
  208.       msg '****** AUTO_NEW_FILE_LIST - wait is LOST! ******'
  209.    end
  210.    if NRESULT = 'Command ->' then                /* T */ 
  211.       send 't\r'
  212.    if NRESULT = 'Enter Disk Number:' then        /* W */ 
  213.       send '0\r'
  214.    if NRESULT = 'Time Left [' then do            /* X Y */
  215.       TL_loop_count = TL_loop_count + 1
  216.       if TL_loop_count = 1 then 
  217.          send '#'                                /* X */
  218.       if TL_loop_count = 2 then 
  219.          send 'n'                                /* Y */
  220.       if TL_loop_count = 3 then do
  221.          waitlost = 'n'
  222.          send 'q'                                /* AB */
  223.       end
  224.       if TL_loop_count > 3 then do
  225.          waitlost = 'y'
  226.          msg '****** Auto_New_File_List TL_loop_count > 3 ******'
  227.       end
  228.    end
  229.    if NRESULT = 'Search Date' then               /* Z */ 
  230.       send '\r'
  231.    if NRESULT = 'Previous Page:' then            /* AA */ 
  232.       send 'y'
  233.    if waitlost ~= ' ' then 
  234.       leave
  235. end
  236. return
  237.  
  238.  
  239. AUTO_FILE_DL:
  240. OPTIONS RESULTS
  241. address command
  242.  
  243. address BAUD /* must have this here */ 
  244.  
  245. call open('FL','dh1:-dl/DL_FAAX','R')
  246. FLN = readln('FL')
  247. upper FLN
  248. call close('FL')
  249. waitlost = ' '
  250. DL_loop_count = 0
  251. do forever  
  252. nput='Command ->,Enter Disk Number:,Time Left [,Select Protocol:,Choice:,To Download:,Hangup After Transfer?,h To Hangup Now:' 
  253. wait nput  
  254. NRC = RC
  255. NRESULT = RESULT
  256.    if NRC > 0 then do  /* waited 30 seconds & no nput items on serial port */ 
  257.       waitlost = 'y'
  258.       msg '****** AUTO_FILE_DL - wait is LOST! ******'
  259.    end
  260.    if NRESULT = 'Command ->' then                /* AC */                
  261.       send 't\r'
  262.    if NRESULT = 'Enter Disk Number:' then        /* ? */        
  263.       send '0\r'
  264.    if NRESULT = 'Time Left [' then do            /* AD AE ? */           
  265.       DL_loop_count = DL_loop_count + 1
  266.       if DL_loop_count = 1 then                  /* AD */ 
  267.          send '#'                               
  268.       if DL_loop_count = 2 then 
  269.          send 'd'                                /* AE */
  270.       if DL_loop_count = 3 then do
  271.          waitlost = 'n' 
  272.          send 'Q'                                /* AJ */
  273.       end
  274.       if DL_loop_count > 3 then do
  275.          waitlost = 'y'
  276.          msg '****** AUTO_FILE_DL - DL_loop_count > 3 ******'
  277.       end
  278.    end
  279.    if NRESULT = 'Select Protocol:' then          /* AF */          
  280.       send 'Z'
  281.    if NRESULT = 'Choice:' then                   /* AG */                   
  282.       send 'G'
  283.    if NRESULT = 'To Download:' then              /* AH */              
  284.       send FLN'\r'
  285.    if NRESULT = 'Hangup After Transfer?' then    /* AI */    
  286.       send 'N'
  287.    if waitlost ~= ' ' then 
  288.       leave
  289. end
  290.  
  291. return
  292.  
  293.  
  294. LOGOFF:
  295. address BAUD /* must have this here */
  296.  
  297. waitlost = ' '
  298. CMD_loop_count = 0
  299. do forever
  300. nput='Command ->' 
  301. wait nput
  302. NRC = RC
  303. NRESULT = RESULT
  304.    if NRC > 0 then do  /* waited 30 seconds & no nput items on serial port */
  305.       waitlost = 'y'
  306.       msg '****** Logoff wait is LOST! ******'
  307.    end
  308.    if NRESULT = 'Command ->' then do             /* AK AL */ 
  309.       CMD_loop_count = CMD_loop_count + 1
  310.       if CMD_loop_count = 1 then 
  311.          send 'g\r'                              /* AK */
  312.       if CMD_loop_count = 2 then do
  313.          waitlost = 'n'
  314.          send 'y\r'                              /* AL */
  315.       end
  316.       if CMD_loop_count > 2 then do
  317.          waitlost = 'y'
  318.          msg '****** LOGOFF - CMD_loop_count > 2 ******'
  319.       end
  320.    end
  321.    if waitlost ~= ' ' then 
  322.       leave
  323. end
  324. return
  325.  
  326.